<template>
    <div>
        <el-card class="!border-none mt-4" shadow="never">
            <el-tabs v-model="tabsActive" @tab-change="getLists">
                <el-tab-pane
                    v-for="(item, index) in tabsMap"
                    :key="index"
                    :label="item.name"
                    :name="item.type"
                    lazy
                ></el-tab-pane>
            </el-tabs>
            <el-table class="mt-[20px]" size="large" :data="pager.lists" v-loading="pager.loading"
			:header-cell-style="{'background':'#0054A6','color':'#FFB400','line-height':'52px','padding':'14px 0'}"
			:cell-style="{'color':'#0054A6','padding':'20px 0'}"
			>
                <el-table-column label="标题内容" prop="scene_name" align="center" >
					<template #default="{ row }">
					    <el-button type="primary" link>
					        <router-link
					            :to="{
					                path: getRoutePath('message.message/detail'),
					                query: {
					                    id: row.id
					                }
					            }"
					        >
					            <span class="main-color">{{row.scene_name}}</span>
					        </router-link>
					    </el-button>
					</template>
				</el-table-column>
                <el-table-column label="时间" prop="type_desc" align="center" />
               <!-- <el-table-column label="短信通知" min-width="80">
                    <template #default="{ row }">
                        <el-tag v-if="row.sms_notice?.status == 1">开启</el-tag>
                        <el-tag type="danger" v-else>关闭</el-tag>
                    </template>
                </el-table-column> -->
                <el-table-column label="操作" fixed="right" align="center" >
                    <template #default="{ row }">
                        <el-button 
						type="primary" 
						link
						@click="handleDelete(row.id)"
						>
                            <span class="main-color1">删除</span>
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-card>
    </div>
</template>
<script lang="ts" setup name="notice">
import { noticeLists } from '@/api/message'
import { usePaging } from '@/hooks/usePaging'
import { getRoutePath } from '@/router'
import feedback from '@/utils/feedback'

enum NoticeEnums {
    USER = 1,
    PLATFORM = 2,
	HasRead = 3
}

const tabsActive = ref(NoticeEnums.USER)
const tabsMap = [
    {
        name: '全部',
        type: NoticeEnums.USER
    },
    {
        name: '未读',
        type: NoticeEnums.PLATFORM
    },
	{
	    name: '已读',
	    type: NoticeEnums.HasRead
	}
]

// 列表数据
const params = reactive({
    recipient: tabsActive
})
const { pager, getLists } = usePaging({
    fetchFun: noticeLists,
    params
})
const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    // await menuDelete({ id })
    getLists()
}
onActivated(() => {
    getLists()
})

getLists()
</script>
<style>
	.el-tabs__item.is-active{
		color: var(--el-text-color-main);
		font-weight: bold;
	}
	.el-tabs__nav-wrap::after{
		background-color: #F5F5F5;
	}
	.el-tabs__active-bar{
		background-color: var(--el-text-color-main);
	}
</style>
